package cn.zhizihua.controller;

import cn.zhizihua.pojo.Address;
import cn.zhizihua.query.AddressQuery;
import cn.zhizihua.service.IAddressService;
import cn.zhizihua.vo.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Api(value = "地址的API",description="地址相关的CRUD功能")
@RestController     //等于 @Controller+@ResponseBody响应参数为json
@RequestMapping("/address")   //配置请求路径  接收所有的请求方式   放在类上（模块路径）   方法上（方法路径）  方法后续具体路径@PostMapping....
public class AddressController extends BaseController<Address,AddressQuery>{

    @Autowired
    IAddressService addressService;

    @ApiOperation(value = "通过用户id查询地址信息")
    @GetMapping("/user/{userId}")    //   get +  /address/user/1
    public ResultBean getByUserId(@PathVariable("userId") Integer userId){
        System.out.println("--------AddressController--------getByUserId---------");
        System.out.println(userId);
        return addressService.getByUserId(userId);
    }

}
